<?php
class UserModel extends Model
{
    function __construct()
    {
        parent::__construct();
        $this->loadTable('users');
    }
    public function getUser($id)
    {
        $condition = array('id' => $id);
        return $this->tables['users']->get($condition);
    }

    public function updatePassword($userid,$password,$name = NULL)
    {
        $this->tables['users']->set('password',$password);
        $this->tables['users']->set('name', $name);
        $condition = array('id' => $userid);
        $this->tables['users']->update($condition);
    }

    public function find()
    {
        $condition = NULL;
        if(isset($_POST['user_id']) && $_POST['user_id'] != NULL)
        {
            $condition['id'] = array('LIKE',"%$_POST[user_id]%");
        }
        if (isset($_POST['user_name']) && $_POST['user_name'] != NULL)
        {
            $condition['name'] = array('LIKE', "%$_POST[user_name]%");
        }
        $rs = $this->tables['users']->get($condition);
        return $rs;
    }
}
 
